PPS LAB

Program to find factorial/product of first n natural numbers using for loop

Requirement: Algorithm Program (Without Function) #include<stdio.h> int main() { printf(“***************************************************************”); printf(“\n***************************************************************”); printf(“\n** WAP to print factorial/product of first n natural numbers **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n***************************************************************”); printf(“\n***************************************************************\n”); int n,p=1,i; printf(“Enter no upto which you want to multiply\n”); scanf(“%d”,&n); for(i=1;i<=n;i++) p=p*i; printf(“factorial/Product of first %d …

Program to find factorial/product of first n natural numbers using for loop Read More »

Program to print sum of first n natural numbers using for loop

Logic: Enter the number n sum= 1 + 2+ 3 + 4 +……..+n Algorithm Enter the number as n Initially assign sum=0 for(i=1;i<=n;i++) sum=sum+i; Print sum Program #include<stdio.h> int main() { printf(“****************************************************************”); printf(“\n****************************************************************”); printf(“\n** WAP to print sum of first n natural numbers using for loop **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant …

Program to print sum of first n natural numbers using for loop Read More »

Program to print numbers from a to b using for loop

Program #include <stdio.h> int main() { printf(“****************************************************************”); printf(“\n****************************************************************”); printf(“\n** WAP to print numbers from a to b using for loop **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n****************************************************************”); printf(“\n****************************************************************\n”); int a, b, i; printf(“enter a and b”); scanf(“%d%d”, &a, &b); if (a <= b) { printf(“\n\nNumbers in …

Program to print numbers from a to b using for loop Read More »

Program to print even numbers from 10 to 1 using for loop

Program #include <stdio.h> int main() { printf(“***********************************************************”); printf(“\n***********************************************************”); printf(“\n** WAP to print even numbers from 10 to 1 using for loop **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n***********************************************************”); printf(“\n***********************************************************\n”); int i; printf(“\nLogic 1\n”); for (i = 10; i >= 2; i = i – 2) printf(“%d\t”, …

Program to print even numbers from 10 to 1 using for loop Read More »

Program to print even numbers from 1 to 10 using for loop

Program #include <stdio.h> int main() { printf(“****************************************************************”); printf(“\n****************************************************************”); printf(“\n** WAP to print even numbers from 1 to 10 using for loop **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n****************************************************************”); printf(“\n****************************************************************\n”); int i; printf(“\nLogic 1\n”); for (i = 2; i <= 10; i = i + 2) printf(“%d\t”, …

Program to print even numbers from 1 to 10 using for loop Read More »

Program to print numbers 10 to 1 using for, while and do while loop

Program #include <stdio.h> int main() { printf(“*********************************************************”); printf(“\n*********************************************************”); printf(“\n** WAP to print numbers 10 to 1 using loops **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n*********************************************************”); printf(“\n*********************************************************\n”); int i; printf(“\nUsing For loop\n”); for (i = 10; i >= 1; i–) printf(“%d\t”, i); printf(“\n\nUsing while loop\n”); i = …

Program to print numbers 10 to 1 using for, while and do while loop Read More »

Program to print numbers 1 to 10 using for, while and do while loop

Program #include <stdio.h> int main() { printf(“******************************************************”); printf(“\n******************************************************”); printf(“\n** WAP to print numbers 1 to 10 using loops **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n******************************************************”); printf(“\n******************************************************\n”); int i; printf(“\nUsing For loop\n”); for (i = 1; i <= 10; i++) printf(“%d\t”, i); printf(“\n\nUsing while loop\n”); i = …

Program to print numbers 1 to 10 using for, while and do while loop Read More »

Program to print name of month depending upon entered month number

Logic: Enter month number Month name starts from January If month number=1, month is January If month number=2, month is February and so on If month number=12, month is December Otherwise, you have entered Wrong month number Algorithm Enter month number as mno switch (mno) { case 1: printf(“january”); break; case 2: printf(“feburary”); break; case …

Program to print name of month depending upon entered month number Read More »

error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.