SlideShare a Scribd company logo
http://eglobiotraining.com
The first programming source
code will show how to compute for
the sum of the number entered by
the user by using the C language
programming.




         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 the
programming 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);
else
printf("%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 GLOBIO

SUBMITTED BY: FRANZ NERI CLEMEÑA

FM09205 W-S 10:30AM-12:00PM



Official Website is http://eglobiotraining.com/




                http://eglobiotraining.com

More Related Content

PPTX
comp2
DOC
C lab-programs
PDF
88 c-programs
DOCX
Core programming in c
DOCX
C Programming
DOCX
Practical write a c program to reverse a given number
PDF
The solution manual of c by robin
DOCX
C programs
comp2
C lab-programs
88 c-programs
Core programming in c
C Programming
Practical write a c program to reverse a given number
The solution manual of c by robin
C programs

What's hot (19)

PPTX
Simple c program
DOCX
C Programming
PDF
First c program
DOCX
C programming Lab 2
PPT
DOCX
Practical write a c program to reverse a given number
DOC
Programming egs
DOCX
B.Com 1year Lab programs
DOCX
C programming Lab 1
DOC
C program to check leap year
DOCX
Programming fundamentals
RTF
PPTX
Testing lecture after lec 4
PDF
Chapter 4 : Balagurusamy Programming ANSI in C
PPTX
C Programming Example
DOCX
C Language Programs
PDF
Chapter 5 exercises Balagurusamy Programming ANSI in c
PDF
C Programming Example
PPTX
Chap 2 input output dti2143
Simple c program
C Programming
First c program
C programming Lab 2
Practical write a c program to reverse a given number
Programming egs
B.Com 1year Lab programs
C programming Lab 1
C program to check leap year
Programming fundamentals
Testing lecture after lec 4
Chapter 4 : Balagurusamy Programming ANSI in C
C Programming Example
C Language Programs
Chapter 5 exercises Balagurusamy Programming ANSI in c
C Programming Example
Chap 2 input output dti2143
Ad

Viewers also liked (7)

PDF
Health Affairs
PPTX
PPT
Familo prezentacja
PPT
Familo prezentacja
PPTX
Classsourcing: Crowd-Based Validation of Question-Answer Learning Objects @ I...
PPTX
Jsimko wikt2012 v01
PPT
Familo prezentacja
Health Affairs
Familo prezentacja
Familo prezentacja
Classsourcing: Crowd-Based Validation of Question-Answer Learning Objects @ I...
Jsimko wikt2012 v01
Familo prezentacja
Ad

Similar to comp1 (20)

PDF
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
PDF
Programming in C Lab
PDF
Cse115 lecture08repetitionstructures part02
PPTX
Looping programs that runs based on conditions
PPT
Lecture 13 Loops1 with C++ programming.PPT
PPTX
All type looping information and clearly
ODT
DOC
Slide07 repetitions
DOC
Datastructure notes
PDF
5 c control statements looping
PPTX
Programming ppt files (final)
DOCX
OverviewThis hands-on lab allows you to follow and experiment w.docx
PPT
Lập trình C
PPT
2. Data, Operators, IO.ppt
PPTX
Each n Every topic of C Programming.pptx
PDF
2 EPT 162 Lecture 2
PPTX
C programming language
PPTX
Looping statements c language basics ppt with example
PPTX
Looping statements.pptx for basic in c language
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Programming in C Lab
Cse115 lecture08repetitionstructures part02
Looping programs that runs based on conditions
Lecture 13 Loops1 with C++ programming.PPT
All type looping information and clearly
Slide07 repetitions
Datastructure notes
5 c control statements looping
Programming ppt files (final)
OverviewThis hands-on lab allows you to follow and experiment w.docx
Lập trình C
2. Data, Operators, IO.ppt
Each n Every topic of C Programming.pptx
2 EPT 162 Lecture 2
C programming language
Looping statements c language basics ppt with example
Looping statements.pptx for basic in c language

comp1