Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Hello World For All Languages For Beginners

New comers for beginner hello world

  • Please log in to reply
5 replies to this topic

#1 sun13zenith

sun13zenith

    CC Newcomer

  • Member
  • PipPip
  • 12 posts
  • Programming Language:C, Java, C++, PHP
  • Learning:C, Java, C++, PHP

Posted 15 May 2012 - 06:42 PM

Hello World...

I am new to programming. And my choice of language to start programming is C. The conclusion came after googling throughout the web and found much easy and comfortable and powerful language. But not compared to other oops languages.

Hello Programmers.

What are the uses of FOR loops. We should use WHILE or FOR in general.
  • 0

#2 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 15 May 2012 - 07:22 PM

All languages provides the 'loop' (in C 'for', 'while' & 'do/while') construct so that the user of the languages can write code to perform 'repeated' tasks. As example, in C, you can print you name with "printf("sun13zenith);" single time. But what if you want to print your name for 100 times, or millions of times or for just forever? Well, you can print 100 times with 100 "printf("sun13zenith);" statements. But that will make your code bigger. The loop constructs come in this essence. So to print your name 100 times or forever as follows in C.
int i;
// print your name 100 times
for(i = 0; i < 100; ++i) {
	 printf("sun13zenith");
}


// print your name forever
for(;<img src='http://forum.codecall.net/public/style_emoticons/<#EMO_DIR#>/wink.png' class='bbc_emoticon' alt=';)' /> {
	 printf("sun13zenith");
}


// forever using while
while(1) {
	 printf("sun13zenith");
}



Wiki links for for/while/do-while construct...
  • 1

#3 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 16 May 2012 - 04:47 AM

hello sun13zenith welcome to codecall community.
I use for loops for counting and displaying elements of an array or for an easy loop and I use while loop for a more controlled loop where I can decide to stop it or continue executing the loop :)

Have fun coding
  • 1
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#4 fread

fread

    Programming God

  • Senior Member
  • PipPipPipPipPipPip
  • 897 posts
  • Location:Trinidad and Tobago
  • Learning:C, Java, C++, C#, PHP, Python, PL/SQL

Posted 18 May 2012 - 05:06 AM

Welcome to Codecall, sun13zenith! As you can C, I love C. :nervous: Its been a while since I wrote any code in C though. :worry:
  • 1

#5 sun13zenith

sun13zenith

    CC Newcomer

  • Member
  • PipPip
  • 12 posts
  • Programming Language:C, Java, C++, PHP
  • Learning:C, Java, C++, PHP

Posted 20 May 2012 - 10:00 PM

Thank you all (kernelcoder, papabear and fead and all members)...

********************************
by the way, following is a code which confuses me:


/*A program of selections...[sun13zenith]*/
#include<stdio.h>
int selection(int);
void main()
{
    int option, option1, i;
    i=1;
    char ch;

    while(i)
    {
	    option=selection(option1);

	    if(option>=1&&option<=4)
	    {

		    switch(option)
		    {
			    case 1:
				    printf("\nYou are now booting to Windows XP");

				    //printf("\nGO BACK \(Y/N\) : ");
				    //scanf("%d", &ch);
				    //if(ch==89||ch==121)
					    break;
				    //else
					    //i=0;

			    case 2:
				    printf("\nYou are now booting to Windows Vista");
				    printf("\nGO BACK \(Y/N\) : ");
				    scanf("%d", &ch);
				    if(ch==89||ch==121)
					    main();
				    else
					    break;
			    case 3:
				    printf("\nYou are now booting to Windows 7");
				    printf("\nGO BACK \(Y/N\) : ");
				    scanf("%d", &ch);
				    if(ch==89||ch==121)
					    main();
				    else
					    break;
			    case 4:
				    exit(0);
		    }

		    printf("\nGO BACK \(Y/N\) : ");
		    scanf("%d", &ch);
		    if(ch==89||ch==121)
			    break;
		    else
			    exit(0);
	    }
	    else
		    break;
    }
}

selection(int option1)
{
    int option;
    option=option1;

    printf("\nBOOT OPTIONS");
    printf("\n1. Boot with Windows XP\n2. Boot with Windows Vista\n3. Boot with Windows 7\n4. EXIT");

    printf("\n\nSelect any option=");
    scanf("%d", &option);

	    return(option);
}

---------------
Actually, I am creating a menu selection program but don't know how to ask the user(the imaginery user) if he selects option 1 for example and after executing all the code in case 1 of switch the case 1 should ask the user whether to continue executing the same code or exit to beginning of while(1). Please help.
  • 0

#6 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 21 May 2012 - 10:25 AM

welcome aboard!
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/






Also tagged with one or more of these keywords: New comers, for beginner, hello world

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download