vivekkumarsimra2042
7 views
11 slides
Aug 31, 2025
Slide 1 of 11
1
2
3
4
5
6
7
8
9
10
11
About This Presentation
C programm ppt 10 codes
Size: 40.37 KB
Language: en
Added: Aug 31, 2025
Slides: 11 pages
Slide Content
C Programming Practical Assignment 60 Programs with Aim, Code, Input & Output Stylish Professional PPT
Program 1: Hello World 💻 Aim: Write a program to display 'Hello World' on screen Code: #include <stdio.h> int main(){ printf("Hello World"); return 0; } Input: No input Output: Hello World
Program 2: Add Two Numbers 🧮 Aim: Write a program to add two integers Code: #include <stdio.h> int main(){ int a,b; scanf("%d%d",&a,&b); printf("Sum=%d",a+b); return 0; } Input: 5 3 Output: Sum = 8
Program 3: Find Square 🔢 Aim: Write a program to find square of a number Code: #include <stdio.h> int main(){ int n; scanf("%d",&n); printf("Square=%d",n*n); return 0; } Input: 4 Output: Square = 16
Program 4: Swap Two Numbers 🔄 Aim: Write a program to swap two numbers Code: #include <stdio.h> int main(){ int a,b,temp; scanf("%d%d",&a,&b); temp=a;a=b;b=temp; printf("After Swap: %d %d",a,b); return 0; } Input: 5 10 Output: After Swap: 10 5
Program 5: Check Even or Odd ⚖️ Aim: Write a program to check even or odd Code: #include <stdio.h> int main(){ int n; scanf("%d",&n); if(n%2==0) printf("Even"); else printf("Odd"); return 0; } Input: 5 Output: Odd
Program 6: Factorial 📐 Aim: Write a program to find factorial of a number Code: #include <stdio.h> int main(){ int n,f=1; scanf("%d",&n); for(int i=1;i<=n;i++) f*=i; printf("Factorial=%d",f); return 0; } Input: 5 Output: Factorial = 120
Program 7: Fibonacci Series 📊 Aim: Write a program to print Fibonacci series Code: #include <stdio.h> int main(){ int n,a=0,b=1; scanf("%d",&n); for(int i=0;i<n;i++){ printf("%d ",a); int t=a+b;a=b;b=t; } return 0; } Input: 5 Output: 0 1 1 2 3
Program 8: Largest of Three 🏆 Aim: Write a program to find largest of 3 numbers Code: #include <stdio.h> int main(){ int a,b,c; scanf("%d%d%d",&a,&b,&c); if(a>b && a>c) printf("%d",a); else if(b>c) printf("%d",b); else printf("%d",c); return 0; } Input: 5 7 3 Output: 7
Program 9: Check Prime 🔑 Aim: Write a program to check prime number Code: #include <stdio.h> int main(){ int n,flag=1; scanf("%d",&n); for(int i=2;i<n;i++){ if(n%i==0){flag=0;break;} } if(flag) printf("Prime"); else printf("Not Prime"); return 0; } Input: 7 Output: Prime
Program 10: Reverse a Number 🔃 Aim: Write a program to reverse digits of number Code: #include <stdio.h> int main(){ int n,r=0; scanf("%d",&n); while(n>0){ r=r*10+n%10; n/=10; } printf("Reversed=%d",r); return 0; } Input: 123 Output: 321