comp1
Upcoming SlideShare
Loading in...5
×
 

comp1

on

  • 269 views

 

Statistics

Views

Total Views
269
Views on SlideShare
269
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

comp1 comp1 Presentation Transcript

  • http://eglobiotraining.com
  • The first programming sourcecode will show how to compute forthe sum of the number entered bythe user by using the C languageprogramming. http://eglobiotraining.com
  • #include<stdio.h>#include<conio.h>main(){int num,sum=0,i;printf("enter integer:");scanf("%d",&num);for(i=0;i<=num;i++)sum=sum+i;printf("answer is %d",sum);getch();} http://eglobiotraining.com
  • The example for this programming source Code is the user enter number 5. So the program will Start to compute from 5 and adding numbers 4, 3, 2 and 1. So the output will be 15. http://eglobiotraining.com
  • Here is the example output of theprogramming source code. http://eglobiotraining.com
  • The second programming source code will show us an output of a right triangle depending what the user entered in the program and the number of asterisk is depends also on the number that the user entered. http://eglobiotraining.com
  • #include<stdio.h>#include<conio.h>int size,j,i;main(){ printf("enter size:"); scanf("%d",&size); for(i=1;i<=size;i++) {for(j=1;j<=i;j++)printf("*");printf("n");}getch();} http://eglobiotraining.com
  • For example the user entered number 5 in the program. So the programming output will show 5 rows of asterisk starting from 1 and ends with 5 asterisk on the fifth row. http://eglobiotraining.com
  • Here is the example output of the programming source code. http://eglobiotraining.com
  • The 3rd programming source code will determine if the number that we enter is a prime or not. http://eglobiotraining.com
  • #include<stdio.h>#include<conio.h>int r,N,ctr,d;main(){printf("enter number:");scanf("%d", &N);ctr=0;d=1;do {r=N%d; if(r==0) ctr++;d++;}while (d<=N);if(ctr==2)printf("%d:PRIME", N);elseprintf("%d:NOT PRIME",N);getch();} http://eglobiotraining.com
  • For example the user input the number 13. The program will start executing if number 13 is prime or not. The output of the programming source code is that it is a prime. http://eglobiotraining.com
  • The 4th programming source code will show us the sum of all numbers starting from 1 and ending with 10. http://eglobiotraining.com
  • #include<stdio.h>#include<conio.h>main(){int ctr=1,sum=0;while(ctr<=10){if(ctr%2!=0)sum=sum+ctr;ctr++;}printf("sum of all odd numbers from 1 to 10 is %d",sum);getch();} http://eglobiotraining.com
  • If the user starts the programming source code, the program will automatically calculate the adding oll the odd numbers from 1 to 10 and the sum is 25. http://eglobiotraining.com
  • The fifth programming source code shows the sum of two integers and after showing the output, the programming source code also indicates whether you would like to try again or not. http://eglobiotraining.com
  • #include<stdio.h>#include<conio.h>main(){int num1,num2,sum;char Resp;do{printf("enter 2 numbers:");scanf("%d %d", &num1, &num2);sum=num1+num2;printf("the sum of %d and %d is %dn", num1,num2,sum);printf("n TRY AGAIN [Y/N]?:");scanf("%c",&Resp);} while ((Resp)==Y);getch();} http://eglobiotraining.com
  • For example for this programming source code:The user inputed integers 13 and 12. So the program will compute the sum of 13 and 12 and the programming output is 25. http://eglobiotraining.com
  • http://www.slideshare.net/franzneri/com p1 http://eglobiotraining.com
  • SUBMITTED TO: MR. ERWIN GLOBIOSUBMITTED BY: FRANZ NERI CLEMEÑAFM09205 W-S 10:30AM-12:00PMOfficial Website is http://eglobiotraining.com/ http://eglobiotraining.com