aptech accp2003 Logic Building With C retake

Curriculum: ACCP2003
Semester: 1
Date: 10/22/2003
Duration: 90 minutes
Total Marks: 10

Logic Building With C

Write a menu-based program with the following menu:    [1.5]

1.    Input A & B.
2.    Display square of B.
3.    Calculate total of the number in the square.
4.    Calculate the factorial value of A.
5.    Exit.

Q1. Input A & B    [1.5]
When user chooses 1 from main menu, do the followings:
•    First, display “Enter the value of A: ” and accept integer A.
•    Second, display “Enter the value of B: ” and accept integer B.
•    Then, store A and B into variables in main function and return to the main menu.
This module must be coded in a function which do the followings:
–    Accept arguments by reference (using pointer).
–    Store values from user’s input into variables in main function.

Q2. Display square of B    [2.0]
When user chooses 2 from main menu, display square of B (the square which size A x A and contant numbers of B).
This module must be coded in a function which do the followings:
–    Accept arguments by value.
–    Display results.
For example:

With A = 3
B = 5
The function print:
5 5 5
5 5 5
5 5 5

With A = 5
B = 1
The function print:
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1

Q3. Calculate total of the number in the square    [1.5]
When user chooses 3 from main menu, calculate total of all the number in the square of B (which generated from menu [2]).
This module must be coded in a function which do the followings:
–    Accept arguments by value.
–    Return the result to the main function.
For example:
With A = 3, B = 5
The function return: 45
With A = 5, B = 1
The function return: 25

Q4. Calculate the factorial value of A    [3.0]
When user chooses 4 from main menu, the program calculate the factorial value of A.
This module must be coded in a function which do the followings:
–    Accept an argument by value.
–    Return the result to the main function.
For example:
With A = 3
The function return: 6
With A = 5
The function return: 120

Q5. Exit.    [0.5]
When user chooses 5 from main menu, the program exits.


Example Source: Retake.C

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s