954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

A Few Questions On C

Hi,
I'm revising for an exam comming up in C Programming. Can anyone help by answering some typical questions which might come up in the examination. Any help would be appreciated.


Basic data types

  • What are the different types of data?
  • What are signed and non-signed data types?
  • What is a float used for?
  • Why have a double?

Maths operations

  • If you have an integer, how can you copy this value into a float?
  • What is the size of a double?
  • What is the logic for finding out if a number is a multiple of 4?
  • How can you use if statements to determine more than one feature?
  • How long is a piece of string?

Strings and arrays

  • What happens when you use scanf to enter a string with spaces present?
  • What happens when you use getchar to enter a string with spaces present?
  • How can you extract a string from another string?
  • How can you create an array of floating point numbers?

Structures and unions

  • How do you access the elements of a structure?
  • How can you set values to a specific part of the data structure?
  • Why use structures?
  • Where would you use a union?

Files

  • How do you open a file for reading?
  • How do you open a file for writing?
  • How do you open a file where you can append to the end?
  • How can you read data from a file?
  • How do you write data to a file?
adam37
Newbie Poster
2 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

How about I give you a few links instead of answering all your questions? C Data types
C Type Casting
scanf()
getchar()
C strings
C structs
C unions
C file i/o
Well... there's a lot of information there, so I hope that you don't get too freaked out at all of that. Take what you need, leave the rest. And if you need help on a specific problem or question, feel free to ask it and we'll help you as best we can.

Hope this helps

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

>>What is the size of a double?
depends on operating system and possibly the compiler. But you can use sizeof(double) to get its size.

>>How long is a piece of string?
depends on where you cut it with your scissors. (sorry for the bad joke, I just couldn't resistet temptation :eek: )

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Hi, I'm revising for an exam comming up in C Programming. Can anyone help by answering some typical questions which might come up in the examination. Any help would be appreciated. Basic data types

  • What are the different types of data?
  • What are signed and non-signed data types?
  • What is a float used for?
  • Why have a double?
Maths operations
  • If you have an integer, how can you copy this value into a float?
  • What is the size of a double?
  • What is the logic for finding out if a number is a multiple of 4?
  • How can you use if statements to determine more than one feature?
  • How long is a piece of string?
Strings and arrays
  • What happens when you use scanf to enter a string with spaces present?
  • What happens when you use getchar to enter a string with spaces present?
  • How can you extract a string from another string?
  • How can you create an array of floating point numbers?
Structures and unions
  • How do you access the elements of a structure?
  • How can you set values to a specific part of the data structure?
  • Why use structures?
  • Where would you use a union?
Files
  • How do you open a file for reading?
  • How do you open a file for writing?
  • How do you open a file where you can append to the end?
  • How can you read data from a file?
  • How do you write data to a file?

You certainely need to go through this site http://www.c-faq.com/

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

if you're revising for an exam and still don't know those things you might as well cancel the exam and actually visit your classes the next time the course is taught because you're all but certain to fail (miracles do happen, but don't count on them).

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 
>>How long is a piece of string? depends on where you cut it with your scissors. (sorry for the bad joke, I just couldn't resistet temptation :eek: )

Its twice as long as half its length, of course ;)

Bench
Posting Pro
577 posts since Feb 2006
Reputation Points: 307
Solved Threads: 63
 

is it? I doubt you can say that without giving an appropriate margin for error.
For example if you take that piece of string and cut it in half you're actually removing some molecules which should make it shorter. But the change in bonding might make it longer.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 
>>How long is a piece of string? depends on where you cut it with your scissors. (sorry for the bad joke, I just couldn't resistet temptation :eek: )
Its twice as long as half its length, of course ;)


If you cut off both ends, the string is endless. So there! :p

WaltP
Posting Sage w/ dash of thyme
Moderator
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 
If you cut off both ends, the string is endless. So there! :p

I'm freyed not.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

It would be understandable if you left most of those out and were unsure about some and asked for help, but even though I'm no expert, the majority of those questions are pretty basic. It shows you have not even tried, so you can't expect people to answer those for you.

If you are getting a test on C programming, you should have at least access to those answers even if you don't know them.

Colin Mac
Posting Whiz
327 posts since Sep 2006
Reputation Points: 78
Solved Threads: 22
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You