Programming Questons, Study notes of Computer science

A list of 29 programming exercises in C language, covering topics such as finding prime numbers, calculating factorial, printing Fibonacci series, and more. Each exercise includes a flowchart, algorithm, and code. useful for students learning C programming and looking for practice exercises.

Typology: Study notes

2021/2022

Available from 11/15/2022

luke-james
luke-james 🇯🇲

1 document

1 / 81

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Index
Sr no.
Questions
Page
no.
1.
Write a program in c to find the division of student.
2.
Write a program in c to find prime number or not.
3.
Write a program in c to find the leap year.
4.
Write a progran to calculate factorial of a number.
5.
Write a program in c to calculate power using recursion.
6.
Write a program in c to find even or odd numbers.
7.
Write a program in c to print fabonnaci series.
8.
Write a Function to check uppercase letter.
9.
Write a program in c to function to check lowercase letter.
10.
Find the greater of the three numbers
11.
Write a program in c to type casting implicit explicit.
12.
Write program to display number 1 to 10 in octal, decimal and
hexadecimal system.
13.
write program to generate following pattern.
a)
ABCDEFG
ABC EFG
AB FG
A G
b).
1
1 2
1 2 3
1 2 3 4
c).
*
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51

Partial preview of the text

Download Programming Questons and more Study notes Computer science in PDF only on Docsity!

Index

Sr no. Questions Page no.

  1. Write a program in c to find the division of student.
  2. Write a program in c to find prime number or not.
  3. Write a program in c to find the leap year.
  4. Write a progran to calculate factorial of a number.
  5. Write a program in c to calculate power using recursion.
  6. Write a program in c to find even or odd numbers.
  7. Write a program in c to print fabonnaci series.
  8. Write a Function to check uppercase letter.
  9. Write a program in c to function to check lowercase letter.
  10. Find the greater of the three numbers
  11. Write a program in c to type casting implicit explicit.
  12. Write program to display number 1 to 10 in octal, decimal and hexadecimal system.
  13. write program to generate following pattern. a) ABCDEFG ABC EFG AB FG A G b). 1 1 2 1 2 3 1 2 3 4

c).

d). 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

  1. Write a program to input from user (5 subjects) sum,average.
  2. Write a program to print student marksheet.
  3. Write a program to calculate simple interest.
  4. Write a program in which you declare variable of all data types supported by C language. Get input from user and print the value of each variable with alignment left, right and column width 10. For real numbers print their values with two digits right to the decimal.
  5. Write a program to demonstrate multiplication table input from user till 10.
  6. Write a program to demonstrate addition of two matrix.
  7. Write a program to multiplication of two matrix.
  8. Write a program to get input from user and check matrix then matrix multiplication or print not matrix.
  9. Write a program to print compare two numbers using ternary operators.
  10. Write a program to convert temperature from centigrate to farenhiet.
  11. Write a program to demonstrate betwise operator left shift and right shift operator.
  12. Write a program to demonstrate print to increament and decreament operator
  13. Write a program to calculation of sum of the digit.
  14. Write a program to reverse a string without using library function.
  15. Write a program to demonstrate Call by value.
  16. write a program demonstrate to call by reference.

Q.1 Write a program in c to find the division of student. Ans. Algorithm:- ● Start ● input percentage ● If per >100 invalid percentage ● If Per >=60 Ist division ● If per 50-60 2 nd division ● If Per less than 40 fail ● stop Flowchart:-

#include<stdio.h> #include<conio.h> Void main() { Int per; Clrscr(); Printf(“Enter percentage of student”); Scanf(“%d”,&per); If(per>100) { Printf(“\n invalid percent”); } else if(per>=60) { Printf(“\n first division”); } else if(per<60&&per>=50) { printf(“second division”); } else if(per<50&&per>=40) { printf(“\m third division”); } else {

BCA C Assignment Solutions- MasterProgramming.in Q.2 Write a program in c to find prime number or not. Ans. Flowchart:- False True True false True

Algorithm:- ● Start ● Read number ● i= ● while(i<n) ● if(n%i==0) ● f= ● if(f==1) then print not prime ● else print prime ● end Code:- #include<stdio.h> #include<conio.h> void main() { int n,i,f; f=0; printf("Enter a number"); scanf("%d",&n); i=2; while(i<n) { if(n%i==0) { f=1; break; }

BCA C Language Assignment Solutions- MasterProgramming.in Q.3 Write a program in c to find the leap year. Ans. Algorithm:- ● start ● year ● if(year%4==0) then leap year ● else not leap year ● stop flowchart:- false True

Code:- #include<stdio.h> #include<conio.h> int main() { int year; clrscr(); printf("enter the year :"); scanf("%d",&year); if(year%4==0) { printf("the year %d is leap year",year); } else { printf("the year %d is not leap year",year); } return 0; }

Q.4 Write a progran to calculate factorial of a number. Ans. Flowchart:- false True true Algorithm:- ● start read n if(n>0) then f= if(n==1) then f=f*n and n=n+

write fact -stop else error stop Code:- #include<stdio.h> #include<conio.h> long int facto(int n) { if(n==1) { return 1; } else return n*facto(n-1); } void main() { long int f; int num; printf("Enter any number :"); scanf("%d",&num); if(num>0) { f=facto(num); printf("factorial is %d",f); } else

BCA C Language Assignment Solutions- MasterProgramming.in Q. 5 Write a program in c to calculate power using recursion. Ans. #include<stdio.h> #include<conio.h> long int power(int a,int b) { Long int s=1; Int I; If(b==0) { return 0; } for(i=1;i<=b;i++) { s=s*a; } return s; } Void main() { long int p; int c,d; printf(“Enter any two number\n”);

scanf(“%d%d”,&c,&d); p=power(c,d); printf(“\n power is %d”,p); getch(); } Output:-

#include<stdio.h> #include<conio.h> Void main() { Int n,r; Clrscr(); Printf(“Enter a number:”); Scanf(“%d”,&n); r=n%2; if(r==0) { Printf(“Even number”); } else { Printf(“odd number”); } getch(); } Output:-

Q.7 Write a program in c to print fabonnaci series. Ans. Flowchart:- No Yes