0% found this document useful (0 votes)
82 views

Computer Assignment

This document is a computer programming assignment submitted by student Naveen with UID 19BCS2130 from the CSE-16 branch/section. It includes 5 questions related to programming in C with answers provided as code snippets. The assignment is acknowledged to be for the subject Computer Programming taught by Professor Neeshu Sharma.

Uploaded by

Vinayak Saini
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

Computer Assignment

This document is a computer programming assignment submitted by student Naveen with UID 19BCS2130 from the CSE-16 branch/section. It includes 5 questions related to programming in C with answers provided as code snippets. The assignment is acknowledged to be for the subject Computer Programming taught by Professor Neeshu Sharma.

Uploaded by

Vinayak Saini
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

SUBJECT: Computer Programming

SUBJECT CODE: UCT-145

SUBMITTED BY: SUBMITTED TO:


NAME :- Naveen PROF. :- Ms. Neeshu Sharma
UID NO. :-19BCS2130
BRANCH/SEC:-CSE-16
ACKNOWLEDGMENT

I would like to express my special thanks of gratitude to


my teacher Ms. Neeshu Sharma who gave me the
golden opportunity to do this wonderful assignment of
the subject Computer Programming ,which also helped
me in doing a lot of Research and I came to know about
so many new things I am really thankful to .
Secondly I would also like to thank my roommates and
friends who helped me a lot in finalizing this project
within the limited time frame.
This project will definitely help me in my further study.
Thank You
1. Write a program to check whether the character is
vowel or consonant ?
Ans. #include<conio.h>
#include<stdio.h>
void main()
{
char ch;
printf("\n enter a character");
scanf("%c",&ch);
if (ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' ||
ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U')
printf("\n %c is a vowel",ch);
else
printf("\n %c is a consonant",ch);
getch();
}
2. Create a C program to convert specified days into
years, weeks and days.
Ans. #include<conio.h>
#include<stdio.h>
void main()
{
int days,weeks,years;
printf("\n enter days");
scanf("%d",&days);
years=(days/365);
weeks=(days%365)/7;
days=days-((years*365)+(weeks*7));
printf("\n years %d",years);
printf("\n weeks %d",weeks);
printf("\n days %d",days);
getch();
}
3. Create a program in C to convert days to years,
weeks and days.
Ans. #include<conio.h>
#include<stdio.h>
void main()
{
int days=2245,weeks,years;
years=(days/365);
weeks=(days%365)/7;
days=days-((years*365)+(weeks*7));
printf("\n years %d",years);
printf("\n weeks %d",weeks);
printf("\n days %d",days);
getch();
}
4. For each of the following statements ,explain why it
is notcorrect,and fix it
(a) #include <stdio.h>;
Ans. correct order:
#include<stdio.h>
-> preproccesor directive should not be
terminated with semicolon
(b) int function(void arg1)
{
return arg1-1;
}
Ans. correct order:
int function(int arg1)
{
return arg1-1;
}
-> arg1 is avoid variable which is represents
empty,should notreturn th void values
(c) #define MESSAGE="Happy new year!"
puts(MESSAGE);
Ans. correct order:
#define MESSAGE"Happy new year!"
puts(MESSAGE);
-> Assignment operator should not be usedin
MACRO defintions.
5. Develop an algorithm to find the greater number
between two numbers.
Ans. Step 1 :- Start.
Step 2:- Declare variables a and b.
Step 3 :- Read variables a and b.
Step 4:- If ( a>b )
Display a is the greater number.
Otherwise
Display b is the greater number.
Step 5:- Stop.

You might also like