Professional Documents
Culture Documents
Foc and C Assingment
Foc and C Assingment
.
Q2. Write a flowchart to check whether the number is even or odd.
Answer.
start
Enter a number
If
number%2
==0
stop
Q3. Demonstrate the following DOS commands: to view the contents of a directory,
Change from one directory to another, Create and delete directories, Change from
one drive to another, Copy files, Rename files, Delete files, Format a floppy disk.
Answer.
Syntax:- cd
Example :-
/*code*/
#include<stdio.h>
void main(){
int i, num, n, count;
printf("Enter the range:
");
scanf("%d", &n);
printf("The prime numbers in between the range 1 to %d:",n);
for(num = 1;num<=n;num++){
count = 0;
for(i=2;i<=num/2;i++){
if(num%i==0){
count++;
break;
}
}
if(count==0 && num!= 1)
printf("%d \n",num);
}
}
#include<stdio.h>
int main(){
int x,fact=1,n;
scanf("%d",&n);
for(x=1;x<=n;x++)
fact=fact*x;
return 0;
Factorial of 4 is: 24
Q7 WAP to find the largest number among three given numbers.
Answer:
#include <stdio.h>
int main() {
Ouput:
Answer.
/**
* C program to search element in array
*/
#include <stdio.h>
int main()
{
int arr[MAX_SIZE];
int size, i, toSearch, found;
/*
* If element is not found in array
*/
if(found == 1)
{
printf("\n%d is found at position %d", toSearch, i + 1);
}
else
{
printf("\n%d is not found in the array", toSearch);
}
return 0;
Answer.
#include <stdio.h>
int main() {
scanf("%d", &r);
scanf("%d", &c);
printf("\nEnter elements of 1st matrix:\n");
scanf("%d", &a[i][j]);
scanf("%d", &b[i][j]);
printf("\n\n");
return 0;
Output:
-2 8 7
10 8 6
Answer.
#include<stdio.h>
while (a<=range)
printf("%d\t", a);
c = a+b;
a = b;
b = c;
int main()
int range;
fibonacciSeries(range);
return 0;
0 1 1 2 3 5 8 13 21 34
Answer.
#include<stdio.h>
#include<conio.h>
void main( )
int a = 10, b = 20 ;
int t;
t = *x;
*x = *y;
*y = t;
Output :
Before sawping
A =10 B =20
After sawping
A = 20 B =10
Answer:
Q13: wap to demonstrate the use of structure in c.
Answer.
Define Structures
Before you can create structure variables, you need to define its data type. To define a struct,
the struct keyword is used.
Syntax of struct
struct structureName {
dataType member1;
dataType member2;
...
};
For example,
struct Person {
char name[50];
int citNo;
float salary;
};
Here, a derived type struct Person is defined. Now, you can create variables of this type.
// code
};
int main() {
return 0;
struct Person {
// code
In both cases,
There are two types of operators used for accessing members of a structure.
. - Member operator
Suppose, you want to access the salary of person2. Here's how you can do it.
person2.salary
Example 1: C structs
#include <stdio.h>
#include <string.h>
struct Person {
char name[50];
int citNo;
float salary;
} person1;
int main() {
person1.citNo = 1984;
return 0;
Output:
Salary: 2500.00
In this program, we have created a struct named Person. We have also created a
variable of Person named person1.
In main(), we have assigned values to the variables defined in Person for the
person1 object.
person1.citNo = 1984;
Notice that we have used strcpy() function to assign the value to person1.name.
This is because name is a char array (C-string) and we cannot use the assignment
operator = with it after we have declared the string.
Answer.
The text inside the heading tags <h1>TEXT</h1> shows on the browser. The size of
the text depends on the heading tag.
<h1>TEXT</h1>
The following are the six HTML tags for different heading sizes.
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<!DOCTYPE html>
<html>
<head>
<title>Heading in HTML</title>
</head>
<body>
<h1>This
s is Heading 1</h1>
</body>
</html>
Output:
Paragraphs tags or <p> tags in HTML help us create paragraphs on a web page. On web browsers, paragraphs
display as blocks of text separated from adjacent blocks by blank lines, white spaces, or first-line
first indentation.
You can use a <p> tagg followed by the content you want to display in your paragraph and a </p>. Whenever
the web browser comes across a <p> tag, it starts its contents on a new line.
Example:
<!DOCTYPE html>
<html>
<body>
<h1>The p element</h1>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
Output:
The p element
This is a paragraph.
This is a paragraph.
This is a paragraph.
Q15: wap to create all lists (ordered and unordered ) in html. Also add the
functionality of hyperlinks.
Answer:
Q16: wap to inserts images and tables in html.
Answer:
<!DOCTYPE html>
<html>
<body>
<h2>HTML Image</h2>
<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
</body>
</html>
Output:
Q17:: wap to create forms using th
the various form elements in html.
Answer.
Q4. Demonstrate the steps of mail merge in MS Word.