Saturday 26 May 2012

For Loop in c

When you want to do any operation for multiple times, this time you may use for operation in c. e.g. if you want to write "Hello World" on the screen for hundred times you can use this loop operation.

here is the program
#include<stdio.h>
int main(){
        int i;
        for ( i=0; i<=100; i++ )
       {
           printf("Hello World !!!\n");
       
       
}
       system("PAUSE");
      return 0;
}

Wednesday 16 May 2012

Switch case operation in c

Todaye we have parcticed on switch case operation in c.
here is the code block:

#include <stdio.h>

main()
{
   char option;
  printf("Write your option(Y/N): ");
    scanf("%c",&option);
 switch(option)
 {
    case 'Y':
         printf("Yes, we have a class on friday\n");
         break;
    case 'N':
        printf("No, we don't have any class on friday\n");
        break;
    default:
         printf("write the correct option\n");
         break;
   }
system("PAUSE");
return 0;
}



Saturday 12 May 2012

If and else in c

If you want to compare two or more options, this time you can implement if.. else . the general syntex for if..else is

if ( condition ) {
   expr_set1;
}
else  {
   expr_set2;
}

you can remember from spreadsheet program, whre we used if function for TRUE & FALSE.

The code block of our last solved proram is given below

#include<stdio.h>
int main(){
        int i,j, result;
        printf("Write the two numbers you want compare:");
        scanf("%d %d",&i, &j);
        result = i-j;
        if ( result > 0 )
                printf("%d is greater than %d\n",i,j);
        
        else 
          if ( result < 0 )
             printf("%d is greater than %d\n",i,j);        
       
        else
            if ( result = 0 )
               printf("Both the numbers are equal\n");

     system ("PAUSE");       
     return 0;
}
Here is the screenshot of the program run with the two numbers 45 &90

Tuesday 17 April 2012

Get the value from user

Today we did some simple calculation with the values taken from the user
we have taken 2 numbers and then did the following calculations
1. Adding  2. subtracting 3. multiplication 4. divination
 Here is the code block

#include <stdio.h>
main()
{
    int i,j,result;
      printf("Write the two numbers you want to work with: " );
      scanf("%d %d", &i,&j);
      result= i+j;
      printf(" %d + %d = %d\n",i,j,result );  
      result = i-j;
      printf(" %d -  %d = %d\n",i,j,result ); 
      result = i*j;
      printf(" %d *  %d = %d\n",i,j,result ); 
      result = i/j;
      printf(" %d /  %d = %d\n",i,j,result );
      system("PAUSE");
      return 0; 
   }


Result window


Thursday 12 April 2012

Addition in C 10/04/2012

Here is our first mathematical solution by using C. just adding two numbers
#include <stdio.h>
main()
{
    int i=6,j=9;
    int result;
    result = i+j;
    printf("The addition of 6 and 9 is %d\n", result); //this one will print the given data and text
    system("PAUSE");
    return 0;
}

the  screen is given below

Hello World ! Our first program in C

Here is our first program helloworld.c

#include <stdio.h>
main()
{
     printf("Hello World\n") ; //this one will print the given data and text

     system("PAUSE") ; // to see the result  devc++ editor need this command
}


here is the output of this program

Wednesday 11 April 2012

Inaguration of computer club

Hello,
We have formed a new club. here we are going to publish the news of our club.