0% found this document useful (0 votes)
2 views1 page

M Code

The document presents two C programming examples: one demonstrating primary data types including int, float, char, and double, and another checking if a number is prime. The first program initializes and prints values of different data types, while the second program takes an input number and checks its divisibility to determine if it is prime. Both examples include algorithms and expected outputs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

M Code

The document presents two C programming examples: one demonstrating primary data types including int, float, char, and double, and another checking if a number is prime. The first program initializes and prints values of different data types, while the second program takes an input number and checks its divisibility to determine if it is prime. Both examples include algorithms and expected outputs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Primary Data Types

Aim: To demonstrate primary data types in C.

Algorithm:
1. Start
2. Declare variables
3. Print values
4. Stop

Program:
#include<stdio.h>
int main(){
int a=10; float b=5.5; char c='A'; double d=10.123;
printf("%d %.2f %c %.3lf",a,b,c,d);
return 0;
}

Output:
10 5.50 A 10.123

2. Prime Number

Aim: To check whether a number is prime.

Algorithm:
1. Start
2. Input number
3. Check divisibility
4. Print result
5. Stop

Program:
#include<stdio.h>
int main(){
int n,i,flag=0;
scanf("%d",&n);
for(i=2;i<n;i++){
if(n%i==0){flag=1;break;}
}
if(flag==0) printf("Prime");
else printf("Not Prime");
return 0;
}

Output:
Input: 7 → Prime

You might also like