## GUJARAT TECHNOLOGICAL UNIVERSITY

Diploma Engineering - SEMESTER - 1 (NEW) - EXAMINATION - Winter-2024

Subject Code: DI01000131

Date: 07-01-2025

Subject Name: Computer Programming Fundamentals

Time: 10:30 AM TO 01:00 PM

Total Marks: 70

## Instructions:

1. Attempt all questions.
2. Make Suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
4. Use of simple calculators and non-programmable scientific calculators are permitted.
5. English version is authentic.

|         |       |                                                                                                    | Marks   |
|---------|-------|----------------------------------------------------------------------------------------------------|---------|
| Q.1     | (a)   | Define Flowchart. Write importance of flowchart.                                                   | 03      |
| પ્રશ્ન .1 | ( અ ) | ફ્લોચાર્ટ વ્યાખ્યાયયત કરો .  ફ્લોચાર્ટન ું મહત્વ લખો .                                                              | ૦૩      |
|         | (b)   | Define Algorithm. Write an algorithm to add two integer number.                                    | 04      |
|         | ( બ ) | અલ્ગોયરધમ વ્યાખ્યાયયત કરો . બે પૂર્ાાંક સુંખ્યા ઉમેરવા માર્ે અલ્ગોયરધમ લખો .                                                | ૦૪      |
|         | (c)   | List out operators available in 'C'. Explain any two with example.                                 | 07      |
|         | ( ક ) | 'C'  માું ઉપલબ્ધ ઓપરેર્રોની યાદી બનાવો .  કોઈપર્ બે ઉદાહરર્ સાથે સમજાવો .                                               | ૦૭      |
|         |       | OR                                                                                                 |         |
|         | (c)   | Explain basic structure of C program.                                                              | 07      |
|         | ( ક ) | C  પ્રોગ્રામની મૂળભૂત રચના સમજાવો .                                                                          | ૦૭      |
| Q.2     | (a)   | Explain If-else Statement with suitable example.                                                   | 03      |
| પ્રશ્ન .2 | ( અ ) | If-else Statement  ઉદાહરર્ સાથે સમજાવો .                                                                 | ૦૩      |
|         | (b)   | Write a program to print following pattern.  5  54  543  5432  54321  નીચેની પેર્નટ યપ્રન્ર્ માર્ે પ્રોગ્રામ લખો . | 04      |
|         | ( બ ) | 5  54  543  5432  54321                                                                            | ૦૪      |
|         | (c)   | Explain switch case statement with example.                                                        | 07      |
|         | ( ક ) | switch  case statement   ઉદાહરર્ સાથે સમજાવો .                                                           | ૦૭      |
| OR      | OR    | OR                                                                                                 | OR      |

| Q.2      | (a)   | Explain Break statement with example.                                                                                                                                                             | 03   |
|----------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
| પ્રશ્ન . 2 | ( અ ) | બ્રેક સ્ર્ે ર્મેન્ર્ ઉદાહરર્ સાથે સમજાવો .                                                                                                                                                                       | ૦૩   |
|          | (b)   | Write  a  C  program  to  find  that  entered  number  is  Positive  or  negative  using else if ladder.                                                                                          | 04   |
|          | ( બ ) | એન્ર્ર કરેલ નુંબર પોઝીયર્વ કે નેગેયર્વ શોધવા માર્ે C  પ્રોગ્રામ લખો .                                                                                                                                                   | ૦૪   |
|          | (c)   | Explain while loop with example.                                                                                                                                                                  | 07   |
|          | ( ક ) | While loop  ઉદાહરર્ સાથે સમજાવો .                                                                                                                                                                       | ૦૭   |
| Q. 3     | (a)   | Write a program to find whether character entered by user is alphabet or  digit. If alphabet, whether it is consonant, vowel or special symbol using  nested if else statement or if else ladder. | 03   |
| પ્રશ્ન .3  | ( અ ) | એનર્ર કરેલ અક્ષર મૂળાક્ષર છે કે અુંક છે તે શોધવા માર્ે પ્રોગ્રામ લખો .  જો મૂળાક્ષરો ,  પછી ભલે તે વ્યુંજન હોય ,  સ્વર હોય કે યવયશષ્ટ યચહ્નનો ઉપયોગ કરીને નેસ્ર્ે ડ  if else  સ્ર્ે ર્મેન્ર્ અથવા  if else ladder  થી બનાવો .                               | ૦૩   |
|          | (b)   | Write a C program to read 5 elements of array and print it.                                                                                                                                       | 04   |
|          | ( બ ) | એરેના  5 elements  વાુંચવા માર્ે એક પ્રોગ્રામ લખો અને તેને પ્રદયશટત કરો .                                                                                                                                            | ૦૪   |
|          | (c)   | Define  Array.  Explain  initialization  of  a  one-dimensional  array  with  example.                                                                                                            | 07   |
|          | ( ક ) | એરે વ્યાખ્યાયયત કરો .  One-dimensional  એરેના ઇરનશ્યલાઈઝેશનને ઉદાહરર્ સાથે સમજાવો .                                                                                                                                 | ૦૭   |
| OR       | OR    | OR                                                                                                                                                                                                | OR   |
| Q. 3     | (a)   | Write a C program to if the number entered by user is prime or not.                                                                                                                               | 03   |
| પ્રશ્ન .3  | ( અ ) | ય ઝરે એનર્ર કરેલ નુંબર prime છે કે નથી તે માર્ે C  પ્રોગ્રામ લખો .                                                                                                                                                 | ૦૩   |
|          | (b)   | Write a C Program to Swap Two Numbers using Pointers.                                                                                                                                             | 04   |
|          | ( બ ) | પોઇન્ર્રનો ઉપયોગ કરીને બે નુંબરો સ્વેપ કરવા માર્ે  C  પ્રોગ્રામ લખો .                                                                                                                                                   | ૦૪   |
|          | (c)   | Write a C program to find sum of two 2x2 matrix.                                                                                                                                                  | 07   |
|          | ( ક ) | બે  2x2  મેયર્ િ ક્સનો સરવાળો શોધવા માર્ે  C  પ્રોગ્રામ લખો .                                                                                                                                                       | ૦૭   |
| Q. 4     | (a)   | List out types of Pointer. Explain void pointer.                                                                                                                                                  | 03   |
| પ્રશ્ન . 4 | ( અ ) | પોઈન્ર્રના પ્રકારોની યાદી બનાવો . void Pointer  સમજાવો .                                                                                                                                                        | ૦૩   |
|          | (b)   | Give types of user defined  functions.  Explain  Function  with  arguments  with return values with example.                                                                                      | 04   |
|          | ( બ ) | User defined  ફું ક્શનના પ્રકાર આપો . Function with arguments with return  values  ઉદાહરર્ સાથે સમજાવો .                                                                                                       | ૦૪   |
|          | (c)   | Explain call by value and call by Reference with example.                                                                                                                                         | 07   |
|          | ( ક ) | call by value  અને  call by Reference  ઉદાહરર્ સાથે સમજાવો .                                                                                                                                             | ૦૭   |
| OR       | OR    | OR                                                                                                                                                                                                | OR   |
| Q. 4     | (a)   | What is pointer? Write down characteristics of Pointers.                                                                                                                                          | 03   |
| પ્રશ્ન . 4 | ( અ ) | પોઇન્ર્ર શ ું છે ?  પોઇન્ર્રની લાક્ષયર્કતાઓ લખો .                                                                                                                                                                | ૦૩   |
|          | (b)   | Give  types  of  user  defined  functions.  Explain  Function  with  No  arguments but return a values with  example.                                                                             | 04   |
|          | ( બ ) | User  defined  ફું ક્શનના પ્રકાર આપો .  No  arguments  but  return  a  values  ઉદાહરર્ સાથે સમજાવો .                                                                                                           | ૦૪   |
|          | (c)   | What is  recursion?  Write  a  program  to  find  out  factorial  number  using  recursion.                                                                                                       | 07   |

|          | ( ક )   | યરકઝટન શ ું છે ?  યરકઝટનનો ઉપયોગ કરીને ફેક્ર્ોયરયલ નુંબર શોધવા માર્ે પ્રોગ્રામ લખો .                                                               | ૦૭   |
|----------|---------|-----------------------------------------------------------------------------------------------------------------------------|------|
| Q.5      | (a)     | What is character array? How to declare and initialize it?                                                                  | 03   |
| પ્રશ્ન . 5 | ( અ )   | કેરેક્ર્ર અરે શ ું છે ?  તેને કેવી રીતે  declare  કરવ ું અને ઇનશ્યલાઈઝેશન કરવ ું ?                                                                | ૦૩   |
|          | (b)     | Explain Scope, Visibility and Lifetime of variable.                                                                         | 04   |
|          | ( બ )   | વેયરએબલની  Scope, Visibility and Lifetime  સમજાવો .                                                                             | ૦૪   |
|          | (c)     | Explain below File handling function.  1)fopen()      2)fclose()  3)fgetw()  4)feof()                                       | 07   |
|          | ( ક )   | નીચે ફાઇલ હેન્ડયલુંગ ફું ક્શન સમજાવો .  1)fopen()      2)fclose()  3)fgetw()  4)feof()                                                  | ૦૭   |
|          |         | OR                                                                                                                          |      |
| Q.5      | (a)     | Explain strlen() and strcpy() function with example.                                                                        | 03   |
| પ્રશ્ન . 5 | ( અ )   | strlen() અને   strcpy()  ફું ક્શન ઉદાહરર્ સાથે સમજાવો .                                                                               | ૦૩   |
|          | (b)     | Differentiate User defined function and Library Function.                                                                   | 04   |
|          | ( બ )   | User defined  અને  library Function  વચ્ચે તફાવત આપો .                                                                           | ૦૪   |
|          | (c)     | 1) Write a C Program to read character from File.  2) Write a C Program to display data from File using fprintf() function. | 07   |
|          | ( ક )   | 1) ફાઈલમાુંથી કેરેકર્ર વાુંચવા માર્ેનો  C પ્રોગ્રામ લખો. 2)  ફાઈલમાુંથી  ડેર્ા  display  કરવા  માર્ે   fprintf() ફું ક્શન નો ઉપયોગ કરી  C પ્રોગ્રામ લખો.                | ૦૭   |